package cn.com.hongfu.controller;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import cn.com.hongfu.model.Require;
import cn.com.hongfu.service.RequireService;
@Controller
@RequestMapping("/require")
public class RequireController {
	@Autowired
	public RequireService requireService ;
	@RequestMapping("/list")
	public String requireList(ModelAndView modelAndView,ModelMap modelMap){
		modelMap.addAttribute("rs", requireService.getAll());
		return "/require/requireList";
	}
	@RequestMapping("/add")
	public String add(ModelAndView modelAndView,ModelMap modelMap,HttpServletRequest request){
		Require require = new Require();
		require.setName(request.getParameter("name"));
		require.setSize(request.getParameter("size"));
		require.setAddress(request.getParameter("address"));
		require.setBudget(request.getParameter("budget"));
		require.setChenghu(request.getParameter("chenghu"));
		require.setPhoneNum(request.getParameter("phoneNum"));
		require.setMyQq(request.getParameter("myQq"));
		requireService.save(require);
		modelMap.addAttribute("msg", "您的房屋详细已经保存，我们将尽快与您联系，谢谢！");
		return "/index/require";
	}
}
